package demo1;


import java.util.ArrayList;

class Solution1 {
    public ArrayList<Integer> tmp = new ArrayList<>() ;
    public int[] reverseBookList(ListNode head) {
       reverse(head) ;
       int[] arr = new int[tmp.size()] ;
       for(int i = 0 ; i<arr.length ; i++ ){
         arr[i] = tmp.get(i) ;
       }
       return arr ;

    }
     public void reverse(ListNode head){
       if(head == null){
         return ;
       }
        reverse(head.next) ;
        tmp.add(head.val) ;
     }

}